import { Component } from '@angular/core';
import {ModalController, NavController} from 'ionic-angular';
import {AppService} from "../../services/app.service";

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  slides: Array<any> = [];
  categories: Array<any> = [];
  products: Array<any> = [];

  spinner1: boolean = true;

  params = {
    favoritesId: 2054400,
    pageNo: 1,
    pageSize: 20
  }

  constructor(public appService: AppService,
              public navCtrl: NavController,
              public modalCtrl: ModalController) {
    this.getSlides();
    this.getCategories();
    this.getProducts();
  }
  //获取幻灯片
  getSlides() {
    let slide1 = {
      Title:"移动开发平台",
      PictUrl:"./assets/imgs/banner-1.jpg"
    };
    let slide2 = {
      Title:"移动开发平台",
      PictUrl:"./assets/imgs/banner-2.jpg"
    };
    let slide3 = {
      Title:"移动开发平台",
      PictUrl:"./assets/imgs/banner-3.jpg"
    };
    this.slides.push(slide1,slide2,slide3);
    this.spinner1 = false;
  }
  //获取分类
  getCategories() {
    let ctg1 = {
      Icon:'icon-kujialeqiyezhan_caizhitihuan',
      Title:'人员列表',
      Page:'UserListDemoPage'
    };
    let ctg2 = {
      Icon:'icon-kujialeqiyezhan_VRquanjingtu',
      Title:'列表Demo',
      Page:'MyListDemoPage'
    };
    let ctg3 = {
      Icon:'icon-kujialeqiyezhan_wanzhuanyeshejishi',
      Title:'个人工作台',
      Page:'WorkbenchPage'
    };
    let ctg4 = {
      Icon:'icon-kujialeqiyezhan_gongsishili',
      Title:'Grid组件Demo',
      Page:'GridDemoPage'
    };
    let ctg5 = {
      Icon:'icon-kujialeqiyezhan_shujutongji',
      Title:'Menus组件Demo',
      Page:'MenusDemoPage'
    };
    let ctg6 = {
      Icon:'icon-kujialeqiyezhan_yijianshengchengpeijian',
      Title:'Modals组件Demo',
      Page:'ModalsDemoPage'
    };
    let ctg7 = {
      Icon:'icon-kujialeqiyezhan_tijiaoshenqing',
      Title:'Searchbars组件Demo',
      Page:'SearchbarsDemoPage'
    };
    let ctg8 = {
      Icon:'icon-kujialeqiyezhan_wuxianzhanshikongjian',
      Title:'Segments组件Demo',
      Page:'SegmentsDemoPage'
    };
    this.categories.push(ctg1,ctg2,ctg3,ctg4,ctg5,ctg6,ctg7,ctg8);
  }
  //获取首页推荐列表
  getProducts() {
    this.products = [
      {
        PictUrl:'./assets/imgs/Guidone-1.jpg',
        Title:'AAA'
      },
      {
        PictUrl:'./assets/imgs/Guidone-2.jpg',
        Title:'BBB'
      },
      {
        PictUrl:'./assets/imgs/Guidone-3.jpg',
        Title:'CCC'
      },
      {
        PictUrl:'./assets/imgs/Guidone-4.jpg',
        Title:'DDD'
      }
    ];
  }
  //商品详情
  goDetails(item) {
    console.debug('go details...');
  }


  goList(item){
    console.debug('go list...');
    // if(item.Page != null){
    //   this.navCtrl.push(item.Page, { item: item });
    // }
    let modal = this.modalCtrl.create(item.Page,{ item: item });
    modal.present();
  }


}
